package oj_leetcode;

public class LongestPalindromicSubstring {

    public String longestPalindrome(String s) {
        int length = s.length();
        for (int i = length; i > 0; i--) {
            for (int j = 0; j <= length - i; j++) {
                int left_index = j;
                int right_index = j + i - 1;
                while (left_index < right_index) {
                    if (s.charAt(left_index) == s.charAt(right_index)) {
                        left_index++;
                        right_index--;
                    } else {
                        break;
                    }
                }
                if (left_index >= right_index) {
                    return s.substring(j, j + i);
                }

            }
        }
        return "";
    }


}
